home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # frm - file remove script
- # copyright (c) 2000, joseph cheek, joseph@redmondlinux.org
- # released under gpl.
- #
- # $1: file to remove. can be full pathname, relative to build root,
- # or relative to current dir
- # ex: frm /opt/redmondLinux/builds/21/myfile
- # ex: frm col/install/myfile
- # ex: frm myfile
- #
- # opts: -q: quiet [don't print status messages]
- # -v: verbose
- # -f: force [N/A in this context]
- # -l: language to add to [default: all languages]
-
- # BUG: use getopts instead
- LANG=
- ERROR=0
-
- if [ "n$1" = "n-q" ]; then # -q
- QUIET="-q"
- shift
- fi
-
- if [ "n$1" = "n-v" ]; then # -v
- VERBOSE="-v"
- shift
- fi
-
- if [ "n$1" = "n-f" ]; then # -f
- FORCE="(force)"
- shift
- fi
-
- if [ "n$1" = "n-l" ]; then # -l
- LANG="$2"
- shift
- shift
- fi
-
- if [ ! -r "$1" ]; then # file doesn't exist
- ( echo `basename $0`: can\'t find \"$1\"
- echo
- echo usage: `basename $0` \[-q\] \[-v\] \[-f\] \[-l lang\] file
- echo removes file from redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -v is verbose
- echo -f is force, N/A in this context
- echo -l is language or all if not present ) >&2
- exit 1
- fi
-
-
- # constants and vars
-
- RL_ROOT=/opt/redmondlinux
- BUILD_NUM_FILE=$RL_ROOT/builds/CURRENT_BUILD
- BUILD_NUM=`cat $BUILD_NUM_FILE`
- BUILD_ROOT=$RL_ROOT/builds/$BUILD_NUM
- BUILD_ROOT_LEN=$[ `echo $BUILD_ROOT | wc -c` - 0 ]
- # gives len of build_root plus 1
-
- cd $BUILD_ROOT
- LANG_TO_PROCESS=`echo ${LANG}*`
- cd -
-
- for lang in $LANG_TO_PROCESS; do
-
- CHANGELOG=$BUILD_ROOT/$lang/CHANGELOG
- unset PATH_NAME
-
-
- # file checks
-
- # full pathname and relative to current dir cases
-
- if [ -r "$1" ]; then # file found
- # get fully qualified file name
- pushd `dirname "$1"` > /dev/null
- PATH_NAME=`pwd`/`basename "$1"`
- popd > /dev/null
- fi
-
-
- # relative to build root
-
- if [ -r "$BUILD_ROOT/$lang/$1" ]; then # file found
- # get fully qualified file name
- pushd `dirname "$BUILD_ROOT/$lang/$1"` > /dev/null
- PATH_NAME=`pwd`/`basename "$1"`
- popd > /dev/null
- fi
-
-
- # more error checks
-
- if [ "n$PATH_NAME" = "n" ]; then # file doesn't exist
- ( echo `basename $0`: can\'t find \"$1\"
- echo
- echo usage: `basename $0` \[-q\] \[-v\] \[-f\] \[-l lang\] file
- echo removes file from redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -v is verbose
- echo -f is force, N/A in this context
- echo -l is language or all if not present ) >&2
- ERROR=1
- fi
-
- PATH_HEADER=`echo $PATH_NAME | cut -b 1-$BUILD_ROOT_LEN`
-
- if [ "$PATH_HEADER" != "$BUILD_ROOT/" ]; then # not in build root
- ( echo `basename $0`: $1 not in build root
- echo
- echo usage: `basename $0` \[-q\] \[-v\] \[-f\] \[-l lang\] file
- echo removes file from redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -v is verbose
- echo -f is force, N/A in this context
- echo -l is language or all if not present ) >&2
- ERROR=1
- fi
-
-
- # perform the rm
-
- [ $VERBOSE ] && echo rm -ri "$PATH_NAME"
- rm -ri "$PATH_NAME"
-
- if [ "$?" -gt 0 ]; then # file rm failed
- ( echo `basename $0`: remove failed
- echo please check permissions and try again ) >&2
- ERROR=1
- fi
-
-
- # update changelog
-
- PATH_FOOTER=`echo $PATH_NAME | cut -b $[ $BUILD_ROOT_LEN + 1 ]-`
- echo - $PATH_FOOTER >> $CHANGELOG
-
- if [ "$?" -gt 0 ]; then # update changelog failed
- ( echo `basename $0`: update changelog failed
- echo check permissions on $CHANGELOG ) >&2
- ERROR=1
- fi
-
- [ $QUIET ] || tail -n 1 $CHANGELOG
-
- done
-
- exit $ERROR
-